package io.scnb.lesson001.demo26.test15;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MainConfig15 {
    
    @Bean
    public Service1 service1() {
        return new Service1();
    }
    
    @Bean
    public Service2 service2() {
        return new Service2();
    }

    /**
     * 方法上标注了@Bean，并且方法中是有参数的，spring调用这个方法创建bean的时候，
     * 会把参数中的两个参数注入进来
     * @param s1
     * @param s2
     * @return
     */
    @Bean
    public Service3 service3(Service1 s1, Service2 s2) {
        Service3 service3 = new Service3();
        service3.setService1(s1);
        service3.setService2(s2);
        return service3;
    }
    
}
